<script setup>
import { ref } from 'vue'
import NavBar from './components/NavBar.vue'
import KnowledgeMap from './views/KnowledgeMap.vue'
import KnowledgeEditor from './views/KnowledgeEditor.vue'
import LearningInsights from './views/LearningInsights.vue'

const currentPage = ref('list')
</script>

<template>
  <div class="app-container">
    <NavBar @change-page="currentPage = $event" :currentPage="currentPage" />

    <main class="main-content">
      <KnowledgeMap v-if="currentPage === 'list'" />
      <KnowledgeEditor v-if="currentPage === 'create'" />
      <LearningInsights v-if="currentPage === 'personal'" />
    </main>
  </div>
</template>

<style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Helvetica Neue', Arial, sans-serif;
  background-color: #f8fafc;
  color: #1e293b;
  background-image:
    radial-gradient(circle at 50% 50%, #ffffff 0%, transparent 100%),
    linear-gradient(45deg, #f1f5f9 25%, transparent 25%),
    linear-gradient(-45deg, #f1f5f9 25%, transparent 25%);
  background-size: 100% 100%, 20px 20px, 20px 20px;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  width: 100vw;
}

.main-content {
  width: 1800px;
  margin: 0 auto;
  padding: 1.5rem;
  flex: 1;
}

@media (max-width: 1920px) {
  .main-content {
    width: 1600px;
  }
}

@media (max-width: 1600px) {
  .main-content {
    width: 1400px;
  }
}

@media (max-width: 1440px) {
  .main-content {
    width: 1200px;
  }
}

:root {
  --primary-color: #3b82f6;
  --secondary-color: #6366f1;
  --accent-color: #10b981;
  --background-light: #ffffff;
  --background-dark: #f1f5f9;
  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --knowledge-tech: #3b82f6;
  --knowledge-life: #10b981;
  --knowledge-art: #f59e0b;
  --knowledge-science: #6366f1;
  --card-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --hover-transform: translateY(-5px);
}

/* 卡片基础样式 */
.knowledge-card {
  background: var(--background-light);
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: var(--card-shadow);
  transition: all 0.3s ease;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.knowledge-card:hover {
  transform: var(--hover-transform);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* 按钮基础样式 */
.knowledge-btn {
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.8rem 1.5rem;
  border-radius: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.knowledge-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

/* 输入框基础样式 */
.knowledge-input {
  width: 100%;
  padding: 0.8rem 1rem;
  border: 2px solid var(--background-dark);
  border-radius: 12px;
  font-size: 1rem;
  transition: all 0.3s ease;
  background: var(--background-light);
  color: var(--text-primary);
}

.knowledge-input:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
  outline: none;
}

/* 动画效果 */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* 渐变背景类 */
.gradient-bg {
  background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
}

/* 标题样式 */
.section-title {
  font-size: 1.8rem;
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  font-weight: 600;
}

/* 标签样式 */
.knowledge-tag {
  background: rgba(59, 130, 246, 0.1);
  color: var(--primary-color);
  padding: 0.4rem 0.8rem;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
}

/* 滚动条样式 */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: var(--background-light);
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--secondary-color);
}

/* 连接线样式 */
.connection-line {
  position: absolute;
  background: var(--primary-color);
  opacity: 0.3;
  transition: all 0.3s ease;
}

.connection-line:hover {
  opacity: 0.6;
}

/* 节点样式 */
.knowledge-node {
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
}

.knowledge-node:hover {
  transform: scale(1.05);
}

/* 工具提示样式 */
.tooltip {
  position: absolute;
  background: var(--background-light);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  box-shadow: var(--card-shadow);
  font-size: 0.9rem;
  z-index: 100;
  pointer-events: none;
}

/* 调整卡片网格布局的列数和间距 */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.5rem;
}

.analysis-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(450px, 1fr));
  gap: 1.5rem;
}

/* 添加全局布局类 */
.page-container {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
  gap: 1.5rem;
  width: 100%;
}

.full-width {
  width: 100%;
}

/* 调整所有卡片容器 */
.card-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* 调整网格布局的响应式行为 */
@media (max-width: 1600px) {
  .content-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
  }
}

@media (max-width: 1200px) {
  .content-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  }
}
</style>
